<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>疫情上报系统</div>
<div id="divInfo"></div>
<div id="divTemp"></div>
</body>

<script type="text/javascript">
    function getQueryVariable(variable) {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] === variable) {
                return pair[1];
            }
        }
        return false;
    }
    window.onload = function() {
        var code = getQueryVariable('code');
        document.getElementById('divInfo').innerHTML += '<div>code: ' + code + '</div>';
        if (code) {
            document.getElementById('divInfo').innerHTML += '<div>登录成功</div>';
        } else {
            document.getElementById('divInfo').innerHTML += '<div>正在登录</div>';
            login();
        }
    };

    function login() {
        var appId = 'wxf0e4a930ad9c7360';
        window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appId + '&redirect_uri=http%3a%2f%2ffanyouba.gitee.io%2ftest%2findex.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
    }

</script>
</html>